<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog ">
        <div class="modal-content col-sm-6 col-sm-offset-3">
            <div class="row" style="margin-left:1px; margin-right:1px;">
                <div class="position-relative">
                    <div id="login-box" class="login-box visible widget-box no-border">
                        <div class="widget-body">
                            <div class="widget-main">
                                <h4 class="header blue lighter bigger text-center">
                                    <i class="ace-icon fa fa-coffee green"></i>
                                    后台登录
                                </h4>
                                <form method="post" action="" onsubmit ="return false;">
                                    <fieldset>
                                        <label class="block clearfix" >
                                            <span class="block input-icon input-icon-right">
                                                <input type="text" class="form-control" name="admin_username" id="admin_username" readonly="readonly" value="{:session('userinfo.user_name')}" />
                                                <i class="ace-icon fa fa-user"></i>
                                            </span>
                                        </label>

                                        <label class="block clearfix" style="margin-top:10px;">
                                            <span class="block input-icon input-icon-right">
                                                <input type="password" class="form-control" name="admin_pwd" id="admin_pwd" placeholder="输入密码" />
                                                <i class="ace-icon fa fa-lock"></i>
                                            </span>
                                        </label>

                                        <div class="clearfix" style="margin-top:15px;">

                                            <a href="{:url('admin/Login/logout')}"><button type="button" class="width-35  btn btn-sm  btn-default" style="border-radius:5px;" id="logout">
                                                    <i class="ace-icon fa fa-power-off"></i>
                                                    <span class="bigger-110">退出</span>
                                                </button></a>

                                            <button type="submit" class="width-35 pull-right btn btn-sm btn-primary" style="border-radius:5px;" id="login" >
                                                <i class="ace-icon fa fa-key"></i>
                                                <span class="bigger-110">登录</span>
                                            </button>

                                        </div>

                                        <div class="space-4"></div>
                                    </fieldset>
                                </form>
                            </div><!-- /.widget-main -->
                        </div><!-- /.widget-body -->
                    </div><!-- /.login-box -->
                </div><!-- /.position-relative -->
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    if ("{:session('over_time')}" == 1) {
        $('#loginModal').modal('show');
    } else {
        setInterval(getLastActionTime, parseInt(900) * 1000);
        function getLastActionTime() {
            $.get("{:url('Other/getLastActionTime')}", {},
                    function(data) {
                        if (data == 1) {
                            $('#loginModal').modal('show');
                        }
                    }, 'json' );          
        }
    }

    $("#login").click(function() {
        var $password = $.trim($("#admin_pwd").val());
        $text = document.querySelector('#admin_pwd');
        if ($password.length == 0) {
            layer.alert('密码不能为空', {icon: 5}, function(index) {
                layer.close(index);
            });

        } else {
            $.get("{:url('login/overtime_login')}", {password: $password},
            function(data) {
                if (data == 1) {
                    $('#loginModal').modal('hide');
                } else if(data == 2){
                    location.reload();
                } else {
                    layer.alert('密码错误', {icon: 5}, function(index) {
                        layer.close(index);
                        $("#admin_pwd").val("");
                    });
                }
            },'json' );      
        }
    });
</script>